package cn.usian.controller;

import cn.usian.jyzx.model.dto.h5.UserLoginDto;
import cn.usian.jyzx.model.dto.h5.UserRegisterDto;
import cn.usian.jyzx.model.entity.user.UserAddress;
import cn.usian.jyzx.model.vo.common.Result;
import cn.usian.jyzx.model.vo.h5.UserInfoVo;
import cn.usian.service.UserService;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/user")
public class UserController {
    @Autowired
    UserService userService;

    @GetMapping("/sms/sendCode/{phone}")
    public void sendCodes(@PathVariable String phone){
        userService.sendCode(phone);
    }

    @RequestMapping("/userInfo/register")
    public void userInfo(@RequestBody UserRegisterDto userRegisterDto){
         userService.userInfo(userRegisterDto);
    }

    @RequestMapping("userInfo/login")
    public Result login(@RequestBody UserLoginDto userLoginDto){
        return userService.login(userLoginDto);
    }

    @RequestMapping("userInfo/auth/getCurrentUserInfo")
    public Result<UserInfoVo> getCurrentUserInfo(HttpServletRequest request){

        return userService.getCurrentUserInfo(request);
    }

    @GetMapping("/userAddress/auth/findUserAddressList")
    public Result<List<UserAddress>> findUserAddressList(){
        return userService.findUserAddressList();
    }
}
